function z = dot(x,y)
if ~isa(y,'der1')
  z.v = dot(x.v,y);
  z.d = squeeze(x.d) * y(:);
elseif ~isa(x,'der1')
  z.v = dot(x,y.v);
  z.d = squeeze(y.d) * x(:);
else
  z.v = dot(x.v,y.v);
  z.d = squeeze(x.d) * y.v(:) + squeeze(y.d) * x.v(:);
end

z=class(z,'der1');

